home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 8.5 KB | 273 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: HelloCmd.cpp
- // Release Version: $ 1.0d11 $
- //
- // Author: M.Boetcher
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Hello.hpp"
-
- #ifndef HELLOCMD_H
- #include "HelloCmd.h"
- #endif
-
- #ifndef HELLOPRT_H
- #include "HelloPrt.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfhello
- #endif
-
- //========================================================================================
- // CHelloEditCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand constructor
- //----------------------------------------------------------------------------------------
-
- CHelloEditCommand::CHelloEditCommand(Environment* ev,
- ODCommandID id,
- CHelloPart* itsPart,
- FW_CFrame* frame) :
- FW_CEditCommand(ev, id, frame, FW_kCanUndo),
- fHelloPart(itsPart)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand destructor
- //----------------------------------------------------------------------------------------
-
- CHelloEditCommand::~CHelloEditCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::SaveUndoState(Environment *ev) // Override
- {
- fHelloPart->GetData(ev, fSavedSetting, fSavedTextData);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::UndoIt(Environment* ev)
- {
- FW_CEditCommand::UndoIt(ev); // call inherited
-
- switch (fCommandID)
- {
- case kODCommandCut:
- case kODCommandClear:
- this->RestoreSelection(ev);
- break;
-
- case kODCommandPaste:
- this->SwapSelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::RedoIt(Environment *ev) // Override
- {
- FW_CEditCommand::RedoIt(ev); // call inherited
-
- switch (fCommandID)
- {
- case kODCommandCut:
- case kODCommandClear:
- this->RemoveSelection(ev);
- break;
-
- case kODCommandPaste:
- this->SwapSelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::RemoveSelection
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::RemoveSelection(Environment* ev)
- {
- fHelloPart->ClearData(ev, fSavedSetting);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::RestoreSelection
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::RestoreSelection(Environment* ev)
- {
- fHelloPart->SetData(ev, fSavedSetting, fSavedTextData);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloEditCommand::SwapSelection
- //----------------------------------------------------------------------------------------
-
- void CHelloEditCommand::SwapSelection(Environment* ev)
- {
- FW_CString255 textData;
- FW_Boolean setting;
- fHelloPart->GetData(ev, setting, textData);
- fHelloPart->SetData(ev, fSavedSetting, fSavedTextData);
- fSavedSetting = setting;
- fSavedTextData = textData;
- }
-
- //========================================================================================
- // CHelloDragCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CHelloDragCommand constructor
- //----------------------------------------------------------------------------------------
-
- CHelloDragCommand::CHelloDragCommand(Environment* ev,
- CHelloPart* part,
- FW_CFrame* frame) :
- FW_CDragCommand(ev, frame, FW_kCanUndo),
- fHelloPart(part)
- {
- this->SetMenuStrings(ev, "Undo Move", "Redo Move");
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDragCommand destructor
- //----------------------------------------------------------------------------------------
-
- CHelloDragCommand::~CHelloDragCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDragCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CHelloDragCommand::SaveUndoState(Environment *ev) // Override
- {
- fHelloPart->GetData(ev, fSavedSetting, fSavedTextData);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDragCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloDragCommand::UndoIt(Environment* ev)
- {
- fHelloPart->SetData(ev, fSavedSetting, fSavedTextData);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDragCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloDragCommand::RedoIt(Environment* ev)
- {
- fHelloPart->ClearData(ev, fSavedSetting);
- }
-
- //========================================================================================
- // CHelloDropCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand constructor
- //----------------------------------------------------------------------------------------
-
- CHelloDropCommand::CHelloDropCommand(Environment *ev,
- CHelloPart* itsPart,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint) :
- FW_CDropCommand(ev, itsPart, frame, dropInfo, odFacet, dropPoint, FW_kCanUndo),
- fHelloPart(itsPart)
- {
- this->SetMenuStrings(ev, "Undo Drop", "Redo Drop");
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand destructor
- //----------------------------------------------------------------------------------------
-
- CHelloDropCommand::~CHelloDropCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CHelloDropCommand::SaveUndoState(Environment *ev) // Override
- {
- fHelloPart->GetData(ev, fSavedSetting, fSavedTextData);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloDropCommand::UndoIt(Environment* ev)
- {
- this->SwapSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CHelloDropCommand::RedoIt(Environment* ev)
- {
- this->SwapSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloDropCommand::SwapSelection
- //----------------------------------------------------------------------------------------
-
- void CHelloDropCommand::SwapSelection(Environment* ev)
- {
- FW_CString255 textData;
- FW_Boolean setting;
- fHelloPart->GetData(ev, setting, textData);
- fHelloPart->SetData(ev, fSavedSetting, fSavedTextData);
- fSavedSetting = setting;
- fSavedTextData = textData;
- }
-
-